﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;

using Sunyi.Project.WebPoint.DataContract;

namespace Sunyi.Project.WebPoint.DataAccessController
{
    public partial class SystemInfoDaoController
    {
        public SystemInfo SelectByName(string systemName)
        {
            SystemInfo systemInfo = null;

            Dictionary<Guid, object> systemInfos = CacheProvider.Instance.Get<SystemInfo>();

            foreach (object obj in systemInfos.Values)
            {
                SystemInfo item = obj as SystemInfo;

                if (item != null && item.SystemName == systemName)
                {
                    systemInfo = item;
                    break;
                }
            }

            if (systemInfo == null)
            {
                systemInfo = dao.SelectByName(systemName);
            }

            return systemInfo;
        }

        public int SearchCount(string systemName, bool isActive)
        {
            return dao.SearchCount(systemName, isActive);
        }

        public Collection<SystemInfo> Search(string systemName, bool isActive, int pageIndex, int pageSize)
        {
            return dao.Search(systemName, isActive, pageIndex, pageSize);
        }
    }
}
